<template>
	<view class="beijingse" v-if="pageShow">
		<view class="zzdbbox">
			<view class="strongtext xiaobai fonweight">可用积分</view>
			<view class="sishi xiaobai margin_top2 fonweight">￥
				<text class="xiaobai fonweight" style="font-size: 70rpx;">{{userInfo.score}}</text>
			</view>
		</view>
		<view class="mainpadding" style="position: relative; top: -110rpx;">
			<view class="ffffff radius mainpadding">
				<view class="ershiba xiaohei">转账积分</view>
				<view class="flexbetween margin_top2">
					<view class="sishi xiaohei margin_top2 flexleft fonweight">￥
						<input type="digit" v-model="score" class="xiaohei fonweight" style="font-size: 64rpx;height: 80rpx;" />
					</view>
					<view class="ershiba xiaocheng textcenter" style="min-width: 150rpx;" @click="score=userInfo.score">全部转账</view>
				</view>
			</view>
			<view class="mainpadding radius ffffff margin_top flexleft">
				<view class="titletext xiaohei" style="width: 190rpx;" >对方手机号：</view>
				<input type="number" placeholder="请输入对方手机号" v-model="mobile">
			</view>
			<view class="mainpadding radius ffffff margin_top flexleft">
				<view class="titletext xiaohei" style="width: 190rpx;">支付密码：</view>
				<input type="number" placeholder="请输入支付密码" maxlength="6" v-model="pay_password">
			</view>
			<view class="bigbtn " style="margin-top: 180rpx;" @click="submit">转账</view>
			<view class="xiaocheng textcenter margin_top sanshier" @click="tzzjl">转账记录</view>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				userInfo: {},
				score: "",
				pageShow:false,
				mobile:"",
				pay_password:"",
			}
		},
		onLoad() {
			this.userinfomsg()
		},
		methods: {
			userinfomsg() {
				httpRequest.request('/api/user/index', 'GET', {}).then(res => {
					this.userInfo = res.data
					this.pageShow = true
				})
			},
			submit() {
				uni.showLoading({
					mask:true,
					title:"请稍后"
				})
				if(this.score==""){
					httpRequest.toast("请输入转账积分")
					return false
				}
				if(this.mobile==""){
					httpRequest.toast("请输入对方手机号")
					return false
				}
				if(this.pay_password==""){
					httpRequest.toast("请输入支付密码")
					return false
				}
				httpRequest.request("/api/user/toUserScore", 'GET', {
					score: this.score,
					pay_password: this.pay_password,
					mobile:this.mobile,
				}).then(res=>{
					uni.hideLoading()
					httpRequest.toast(res.msg)
					if(res.code==1){
						setTimeout(()=>{
							uni.navigateBack(1)
						},500)
					}
				})
			},
			// 跳转转账记录
			tzzjl() {
				uni.navigateTo({
					url: '/pages_mypage/zhuanzhuangjl'
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.zzdbbox {
		background-size: 100% 100%;
		padding: 16rpx 30rpx 100rpx;
		background-image: url('https://kuaixun.yuntaiqikeji.com/uploads/20240115/72aba476733bb7cd89b5910c897ea17b.png');
	}
</style>